<?php
//获取参数信息
$fm_id          = $route->bodyParams['fm_id'];
$fm_dir_name    = $route->bodyParams['fm_dir_name'];

/****** 1.更新模块状态为卸载 ****/
$updateParams = array(
    "update_where" => "fm_id",
    "fm_id"        => $fm_id,
    "fm_status"    => 0
);

$R1 = $db->mysqlDB->automaticUpdate($updateParams)->update("sys_organizational_function_module");

/****** 2.删除关联的操作表信息 ****/
$deleteActionParams = array(
    "delete_where" => "ap_fmid",
    "ap_fmid"      => $fm_id,
    "isPhysicallyDelete" => 1
);

$R2 = $db->mysqlDB->automaticDelete($deleteActionParams)->delete("sys_action_permissions");

/****** 3.删除关联的操作类型表信息 ****/
$deleteActionCategoryParams = array(
    "delete_where" => "apc_fmid",
    "apc_fmid"      => $fm_id,
    "isPhysicallyDelete" => 1
);

$R3 = $db->mysqlDB->automaticDelete($deleteActionCategoryParams)->delete("sys_action_permissions_category");

/****** 4.删除关联的菜单表信息 ****/
$deleteMeunParams = array(
    "delete_where" => "m_fmid",
    "m_fmid"      => $fm_id,
    "isPhysicallyDelete" => 1
);

$R4 = $db->mysqlDB->automaticDelete($deleteMeunParams)->delete("sys_menu");

/****** 5.删除业务层文档表信息 ****/
$deleteApiDocsParams = array(
    "delete_where" => "bad_fmid",
    "bad_fmid"      => $fm_id,
    "isPhysicallyDelete" => 1
);

$R5 = $db->mysqlDB->automaticDelete($deleteApiDocsParams)->delete("sys_bussiness_api_docs");

/****** 6.删除业务层文档类别表信息 ****/
$deleteApiDocsCategoryParams = array(
    "delete_where" => "badc_fmid",
    "badc_fmid"      => $fm_id,
    "isPhysicallyDelete" => 1
);

$R6 = $db->mysqlDB->automaticDelete($deleteApiDocsCategoryParams)->delete("sys_bussiness_api_docs_category");

/****** 7.删除业务层文档请求参表信息 ****/
$deleteBussinessApiDocsRequestParams = array(
    "delete_where" => "badrp_fmid",
    "badrp_fmid"      => $fm_id,
    "isPhysicallyDelete" => 1
);

$R7 = $db->mysqlDB->automaticDelete($deleteBussinessApiDocsRequestParams)->delete("sys_bussiness_api_docs_request_parameter");

/****** 8.删除原子层文档请求参表信息 ****/
$deleteApiDocsRequestParams = array(
    "delete_where" => "rp_fmid",
    "rp_fmid"      => $fm_id,
    "isPhysicallyDelete" => 1
);

$R8 = $db->mysqlDB->automaticDelete($deleteApiDocsRequestParams)->delete("sys_request_parameter");

/****** 9.删除原子层相关扩展目录信息 ****/
rmdirr("./extension/".$fm_dir_name);
unlink("./extension/apiConfig/".$fm_dir_name.".api.php");

$response->responseData(true);
